{% extends 'personInfoBase.html' %}
{% block personInfoContentRight %}
<style>
.form-container{
	width: 300px;
	margin: 0 auto;
}
.page-title{
	text-align: center;
}
.transfer{
	background: #fff;
	width: 730px;
	margin: 0 auto;
	overflow: hidden;
}
</style>
<script>
	function transfer() {
	  data = $('#transferForm').serialize()
      $.ajax({
      //几个参数需要注意一下
        type: "POST",//方法类型
		async:false,
        dataType: "json",//从服务端返回的数据类型
        url: "/transactions/new" ,//url
        data: data,
        success: function (result) {
			// alert(result.message);//打印服务端返回的数据(调试用)
			if(result.status==500){
				window.location.href="/transfer/success/"+result.txhash+"/"+result.sender+"/"+result.recipient+"/"+result.amount;
			}
			else{
               $('#transferStatus').text(result.message)
			}
			
        },
        error : function(result) {
			// $("#transferStauts").text(result.responseText);
			alert(result.responseText)
        }
      });
    }
</script>
<div class="transfer" >
	<h3 class='page-title'>转账</h3>
	<form id="transferForm">
		<div class="form-container ">
			<div class="form-group">
				{% if sendaccount=="#" %}
				发送帐号:<input type="text" class="form-control"  placeholder="发送帐号" name="sender" >
				{% else %}
				发送帐号:<input type="text" class="form-control"  placeholder="发送帐号" name="sender" value={{sendaccount}} >
				{% endif %}
			</div>
			<div class="form-group">
				接受帐号:<input type="text" class="form-control"  placeholder="接受帐号" name="recipient">
			</div>
			<div class="form-group">
				<!-- 金额:<input type="number" class="form-control"  placeholder="金额" name="amount" min=0> -->
				金额:<input type="text" class="form-control"  placeholder="金额" name="amount" min=0>
			</div>
			<h5 id="transferStatus">预计1分钟内到帐</h5>
			<div class="form-group">
				<button type="button" class="btn btn-primary btn-block" onclick="transfer()">确认转账</button>
			</div>
			<h5 id="transferStauts"></h5>
		</div>
    </form>
</div>
{% endblock %}